<?php
/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/3/8
 * Time: 10:33
 */

namespace App\Models;

/**
 * Class UserLoginLog
 * @property integer user_id
 * @property string device_id
 * @property string ip
 */
class UserLoginLog extends ApplicationModel
{
    protected $guarded = [];

    public static function save_log($user_id){
        $device_id = empty(request()->header('device-id'))?'':request()->header('device-id');
        $channelid = empty(request()->header('channelid'))?'-1':request()->header('channelid');

        if(request()->header('channelid')==='0')
        {
            $channelid = '0';
        }
        $ip = get_client_ip();
        $data = array();
        $data['user_id'] = $user_id;
        $data['device_id'] = $device_id;
        $data['ip'] = $ip;
        $data['channelid'] = $channelid;
        static::create($data);
    }
}